package tools;

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;

import exception.JDICNotSupported;

public class FileLauncher 
{
	public static final int EDIT_MODE=0;
	public static final int OPEN_MODE=1;
	public static final int PRINT_MODE=2;
	
	Desktop desktop;
	public FileLauncher() throws JDICNotSupported
	{
		if (!Desktop.isDesktopSupported()) 
			throw new JDICNotSupported();
		desktop = Desktop.getDesktop();      
	}	
	public void lunchApplication(File file,int lunchMode) throws IOException,IllegalArgumentException
	{
		switch (lunchMode) 
		{
		case OPEN_MODE:
			desktop.open(file);
			break;
		case EDIT_MODE:
			desktop.edit(file);
			break;
		case PRINT_MODE:
			desktop.print(file);
			break;

		default:
			throw new IllegalArgumentException();
		}
	}
	public void lunchApplication(String file,int lunchMode) throws IOException,IllegalArgumentException
	{
		lunchApplication(new File(file), lunchMode);
	}
}

